import { observer } from 'mobx-react'
import { history } from 'umi'
import IconFont from '@/components/IconFont'
import styles from './index.module.less'
import store from '../../store'
import { deleteData } from '@/servers/http'
import { api } from '@/servers/api'
import { Dialog } from 'antd-mobile'

const PostMatch = () => {
    const { fileDetail, getFileDetail } = store || {}

    const handleClick = (id: number) => {
        history.push(`/postmatch?id=${id}`)
    }

    const handleClickDel = (id: number) => {
        Dialog.confirm({
            content: '是否删除',
            onConfirm: () => {
                deleteData(`${api.userBarriersById}${fileDetail.id}`, { detail_id: id }).then(() => {
                    getFileDetail()
                })
            },
        })
    }

    return (
        <div className={styles.container}>
            <div className={styles.list}>
                {fileDetail.detail.map((item: any) => (
                    <div className={styles.list_item} key={`${item?.code}`}>
                        <div className={styles.item_left} onClick={() => handleClick(item.id)}>
                            <div className={styles.item_name}>
                                <div className={styles.name}>{item.profession_name}</div>
                                <div className={styles.dot}>·</div>
                                <div className={styles.salary}>{item.salary}</div>
                            </div>
                            <div className={styles.company}>{item.company_name}</div>
                        </div>
                        <div className={styles.item_right} onClick={() => handleClickDel(item.id)}>
                            <IconFont type="icon-shanchu" />
                        </div>
                    </div>
                ))}
            </div>
        </div>
    )
}

export default observer(PostMatch)
